{extend name="public:layout" /}
{block name="title"}添加{$moudleName}{/block}
{block name="head"}{/block}
{block name="body"}
<div class="wrapper wrapper-content">
    <div class="ibox">
        <div class="ibox-title">
            <ol class="breadcrumb">
                <li>
                    <i class="fa fa-hand-o-right"></i>
                    <a href="{:url('index',['mid'=>$Request.param.mid,'cid'=>$Request.param.cid])}">{$moudleName}列表</a>
                </li>
                <li class="active">添加{$moudleName}</li>
            </ol>
        </div>
        <div class="ibox-content">
            <form method="post" class="form-horizontal" id="form">
                <div class="form-group">
                    <label class="col-sm-2 control-label Validform_label">出发时间</label>
                    <div class="col-sm-3">
                        <input class="form-control laydatetime" type="text" placeholder="出发时间" name="order_start_time" value="" />
                    </div>
                    <label class="col-sm-2 control-label Validform_label">结束时间</label>
                    <div class="col-sm-3">
                        <input class="form-control laydatetime" type="text" placeholder="结束时间" name="order_end_time" value="" />
                    </div>
                    <script>formatDate();</script>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label Validform_label">客户</label>
                    <div class="col-sm-3">
                        <input type="text" name="btype_id" id="select-client" placeholder="请输入客户名称检索" data-init="" style="width:100%;" />
                        <script>
                            In('selectpage',function(){
                                $('#select-client').selectPage({
                                    keyField:'aid',
                                    showField:'title',
                                    multiple:false,
                                    pagination:true,
                                    dbTable:'car_btype',
                                    data:'/plus/ajax/selectpage',
                                    andOr:'OR',
                                    params : function(){return {'searchField':'company','btype_type':'0'}},
                                    eAjaxSuccess : function(data){
                                        if(data.totalRow>0){
                                            return data;
                                        }else{
                                            return false;
                                        }
                                    },
                                    eSelect:function (data) {
                                        $("input[name='order_client']").val(data.title);
                                        $("input[name='order_phone']").val(data.btype_phone);
                                        $("input[name='order_company']").val(data.company);
                                    },
                                    formatItem : function(data){
                                        return data.company+':'+data.title + '(' + data.btype_phone + ')';
                                    }
                                });
                            })
                        </script>
                    </div>
                    <div class="col-sm-2">
                        <label class="checkbox-inline i-checks">
                            <input type="checkbox" name="is_customer_add" id="is_customer_add" value="1" /> 新增
                        </label>
                    </div>
                </div>
                
                <div class="form-group customer" style="display: none;">
                    <label class="col-sm-2 control-label Validform_label">所在单位</label>
                    <div class="col-sm-3">
                        <input class="form-control" type="text" placeholder="所在单位" name="order_company" value="" datatype="*,s" />
                    </div>
                </div>
                <div class="form-group customer" style="display: none;">
                    <label class="col-sm-2 control-label Validform_label">客户姓名</label>
                    <div class="col-sm-3">
                        <input class="form-control" type="text" placeholder="联系方式" name="order_client" value="" datatype="*,s" />
                    </div>
                    <label class="col-sm-2 control-label Validform_label">联系方式</label>
                    <div class="col-sm-3">
                        <input class="form-control" type="text" placeholder="联系方式" name="order_phone" value="" datatype="*,s" />
                    </div>
                </div>
                <div class="form-group customer">
                    <label class="col-sm-2 control-label Validform_label">导游姓名</label>
                    <div class="col-sm-3">
                        <input class="form-control" type="text" placeholder="导游姓名" name="guide" value="" datatype="*,s" />
                    </div>
                    <label class="col-sm-2 control-label Validform_label">联系方式</label>
                    <div class="col-sm-3">
                        <input class="form-control" type="text" placeholder="联系方式" name="guide_tel" value="" datatype="*,s" />
                    </div>
                </div>
                <div class="form-group customer">
                    <label class="col-sm-2 control-label Validform_label">接团时间</label>
                    <div class="col-sm-3">
                        <input class="form-control laydatetime" type="text" placeholder="接团时间" name="begin_time" value="" />
                    </div>
                    <script>formatDate();</script>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label Validform_label">订单费用</label>
                    <div class="col-sm-3">
                        <input class="form-control" type="text" placeholder="订单费用" name="order_charge" value="0" datatype="*" />
                    </div>
                    <label class="col-sm-2 control-label Validform_label">已付款</label>
                    <div class="col-sm-3">
                        <input class="form-control" type="text" placeholder="" name="order_advance" value="0" datatype="*" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label Validform_label">出发地</label>
                    <div class="col-sm-3">
                        <input class="form-control" type="text" placeholder="出发地" name="order_start_adress" value="" datatype="*" />
                    </div>
                    <label class="col-sm-2 control-label Validform_label">目的地</label>
                    <div class="col-sm-3">
                        <input class="form-control" type="text" placeholder="目的地" name="order_end_adress" value="" datatype="*" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label Validform_label">备注</label>
                    <div class="col-sm-8">
                        <textarea class="form-control" rows="3" name="fleet_desc" ></textarea>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-10 col-sm-offset-2">
                        <button class="btn btn-primary" id="btnSub" type="button">保存</button>
                        <a href="{:url('index',['mid'=>$Request.param.mid])}" class="btn btn-white">取消</a>
                        <span id="validError"></span>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
    $(function () {
        iCheck();
        formatDate();
        ajaxSubForm('#btnSub');
        $("#is_customer_add").on('ifChanged', function(event){
            if($(this).prop('checked')){
                $('.customer').show();
            }else{
                $('.customer').hide();
            }
        });
    });
    function selectCar() {
        var btime=$("input[name='order_start_time']").val();
        var etime=$("input[name='order_end_time']").val();
        if(btime=='' || etime==''){
            alert('请选择出发结束时间！');
            return false;
        }
        top.layer.open({
            title: '选择车辆',
            type: 2,
            area: ['1000px', '450px'],
            content: '/system/logic.select/car.html?btime='+btime+'&etime='+etime,
            btn:["选择","取消"],
            yes:function (index) {
                var cars = top.layer.getChildFrame('#cars', index);
                $("input[name='car_sn']").val(cars.val());
                top.layer.close(index);
            }
        });
    }
</script>
{/block}